<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
	$(function(){
		//페이지가 로딩할 때
		//r_type세션값이 null이 아니면 if문 안에 있는 로직을 수행한다.
		if("${sessionScope.recipeContent.rvo.r_type}"!=null){
			var r_type="${sessionScope.recipeContent.rvo.r_type}";
			//r_type 값의 첫번째값  - substring()메서드 이용
			var r_category=r_type.substring(0,1);
			//r_type 값의 두번째값  - substring()메서드 이용
			var r_nara=r_type.substring(1,2);
			//라디오 중 r_category 만 for문을 돌린다
			$(":radio[name=r_category]").each(function(index){
				//el로 자른 value값과 r_category value들을 하나하나
				//체크한후 값이 동일하면 attr로 checked속성을 true시킴 
				if($(this).val()==r_category){
					$(this).attr("checked","checked");
				}
			}); 
			//라디오 중 r_nara 만 for문을 돌린다
			$(":radio[name=r_nara]").each(function(index){
				//el로 자른 value값과 r_nara value들을 하나하나
				//체크한후 값이 동일하면 attr로 checked속성을 true시킴 
				if($(this).val()==r_nara){
					$(this).attr("checked","checked");
				}
			});
		}
		$("#main_cancle").click(function(){
			if(confirm("수정 하시겠습니까?")){
				location.href="recipe.do?command=update_move&page=2";
			}
		});
		//삭제버튼
		$("#main_ok").click(function(){
			 if(confirm("이 게시물을 삭제하시겠습니까?")){
			    location.href="recipe.do?command=delete&r_no=${sessionScope.recipeContent.rvo.r_no}";
			 }
		});	
			
		$("#main_arrow_next").click(function(){
			$(":hidden[name=pageNo]").val($("#now_pageNo").text());
			$("#pForm_2").submit();
		});
		//1페이지로 가기 위해서 page 값을 1값을 줌
		$("#main_arrow_prev").click(function(){
			location.href="recipe.do?command=getTodayCook&page=1&reply_flag="+$("#reply_flag").val()+"&pageNo="+$("#now_pageNo").text();
		});
		
	});
</script>
<div id="write_container">
<div id="main_page1"><img src="${initParam.root }/img/main/main-write-page2.gif"></div>
<div id="main_arrow_prev"><input type="image" src="${initParam.root }/img/main/main-write-prev.gif"></div>
<div id="main_arrow_next"><input type="image" src="${initParam.root }/img/main/main-write-next.gif"></div>

<c:if test="${sessionScope.recipeContent.rvo.m_id==sessionScope.loginMember.mvoLogin.m_id}">
<div id="main_cancle"><input type="image" src="${initParam.root }/img/main/main-update-btn.gif"></div>
<div id="main_ok"><input type="image" src="${initParam.root }/img/main/main-delete-btn.gif"></div>
</c:if>

<div id="main_kind"><img src="${initParam.root }/img/main/main-write2-kind.gif"></div>
<div id="main_category"><img src="${initParam.root }/img/main/main-write2-category.gif"></div>
<div id="main_nara"><img src="${initParam.root }/img/main/main-write2-nara.gif"></div>

	<div id="main_write_form">
 		<form id="pForm_2" action="recipe.do" method="post">
 		<input type="hidden" name="command" value="getTodayCook">
 		<input type="hidden" name="page" value="3">
 		<input type="hidden" name="pageNo" value="">
 		<input id="reply_flag" type="hidden" name="reply_flag" value="${requestScope.reply_flag}">
 		<div id="main_category_radio">
 			<input type="radio" name="r_category" value="a">국물 &nbsp;
			<input type="radio" name="r_category" value="b">밥 &nbsp;
			<input type="radio" name="r_category" value="c">간식 &nbsp;
			<input type="radio" name="r_category" value="d">육류 &nbsp;
			<input type="radio" name="r_category" value="e">채소 &nbsp;
			<input type="radio" name="r_category" value="f">생선 &nbsp;
			<input type="radio" name="r_category" value="g">면 &nbsp;
			<input type="radio" name="r_category" value="h">제과 &nbsp;
 		</div>
 	
 		<div id="main_nara_radio">
 			<input type="radio" name="r_nara" value="1">한식 &nbsp;
			<input type="radio" name="r_nara" value="2">일식 &nbsp;
			<input type="radio" name="r_nara" value="3">중식 &nbsp;
			<input type="radio" name="r_nara" value="4">양식 &nbsp;
 		</div>
 		</form>
 	</div>
</div>